package top.songxs.gmall.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.product.entity.BaseAttrInfo;
import top.songxs.gmall.product.service.BaseAttrInfoService;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class BaseAttrInfoController {

    @Autowired
    private BaseAttrInfoService baseAttrInfoService;

    //http://api.gmall.com/admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
    @GetMapping("/attrInfoList/{category1Id}/{category2Id}/{category3Id}")
    public Result<List<BaseAttrInfo>> findAttrInfoList(@PathVariable("category1Id") Long c1Id,
                                                       @PathVariable("category2Id") Long c2Id,
                                                       @PathVariable("category3Id") Long c3Id
                                                       ){
        List<BaseAttrInfo> lists = baseAttrInfoService.findAttrInfoList( c1Id,c2Id,c3Id );
        return Result.build(lists, ResultCodeEnum.SUCCESS);
    }

    @PostMapping("saveAttrInfo")
    public Result saveAttrInfo(@RequestBody BaseAttrInfo baseAttrInfo){
        baseAttrInfoService.saveAttrInfo(baseAttrInfo);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }











}
